<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

			<%@ include file="/include/gnb.jsp"%>
			<!-- Main Start -->
			<div id="maincontainer">
				<!-- LeftMenu Start -->
				<div id="leftmenu">
					<%@ include file="/include/lnb.jsp"%>
				</div>
				<!-- Contants Start -->
				<div id="contants">
					<div class="height_10p"></div>
					<form id="commonForm" name="commonForm" method="post">
						<input type="hidden" id="_groupId" name="_groupId" value="${_groupId}" />
						<input type="hidden" id="_menuId" name="_menuId" value="${_menuId}" />
						<input type="hidden" id="_menuNm" name="_menuNm" value="${_menuNm}" />
						<input type="hidden" id="_menuAuth" name="_menuAuth" value="${_menuAuth}" />
						<input type="hidden" id="_prevUpCode" name="_prevUpCode" value="${_prevUpCode}" />
						<input type="hidden" id="_prevCode" name="_prevCode" value="${_prevCode}" />
					</form>
					<div id="ajaxDivList" class="noborder"></div>
				</div>
				<!-- Contants End -->
			</div>
		</div>
		<!-- Footer Start -->
		<div id="footer">
			<%@ include file="/include/footer.jsp"%>
		</div>
	</div>

<script>
var url = "menuAuthMgmt.action";
var params = "target=maList";
var targetElement = "ajaxDivList";

var pmModule = {
		loadList: function() {
			var rParams = params + "&" + $("#commonForm").serialize() + ($("#loadCheck").val() == "OK" ? ($("#isNew").val() == "Y" ? "&searchVal1=" + $("#searchVal1").val() : "&" + $("#searchForm").serialize()) : "");

			this.makeList(url, rParams);
		},
		
		setBinding: function() {
			$(".disable").bind({
				click: function(e) {
					return;
				}
			});
		},
		
		setUnbinding: function() {
			$(".disable").unbind();
		},
		
		selectAuthLevel: function(authLevel) {
			$("#authLevel").val(authLevel);
			$("#menuId").val("");
			$("#menuAuth").val("");
			
			$("#formlist2l .selected").removeClass("selected");
			$("#authLevel" + authLevel).addClass("selected");
			$("#formlist2c .disable").removeClass("disable");
			$("#formlist2c .selected").removeClass("selected");
			$("#formlist2r .ulMenu").addClass("disable");
			
			$("input[type=checkbox]:checked").attr("checked", false);
			$("input[type=checkbox]").attr("disabled","disabled");
		},

		selectMenu: function(that, menuId) {
			if ($(that).hasClass("disable")) return;
			
			$("#menuId").val(menuId);
			$("#menuAuth").val("");
			
			$("#formlist2c .selected").removeClass("selected");
			$("#subMenu_" + menuId).addClass("selected");
			$("#formlist2r .disable").removeClass("disable");
			
			$("input[type=checkbox]:checked").attr("checked", false);
			$("input[type=checkbox]").removeAttr("disabled");

			var rParams = "target=maDetail&" + $("#commonForm").serialize() + "&" + $("#searchForm").serialize();

			this.getMode(url, rParams);
		},

		checkMode: function(mode) {
			var retMode = "0"; // 1(읽기), 2(읽기/쓰기)

			if (mode == "read") {
				if (!$("#modeRead").is(":checked")) {
					$("#modeWrite").attr("checked", false);
				}
			} else {
				if ($("#modeWrite").is(":checked")) {
					$("#modeRead").attr("checked", true);
				}
			}
			
			if ($("#modeWrite").is(":checked")) {
				retMode = "2";
			} else {
				if ($("#modeRead").is(":checked")) {
					retMode = "1";
				}
			}
			
			$("#menuAuth").val(retMode);
			
			var rParams = "target=maSave&" + $("#commonForm").serialize() + "&" + $("#searchForm").serialize();
			
			this.getMode(url, rParams);
		},

		setMode: function() {
			var mode = $("#resultMenuAuth").val();
			
			if (mode == "1") {
				$("#modeRead").attr("checked", true);
				$("#modeWrite").attr("checked", false);
			} else if (mode == "2") {
				$("#modeRead").attr("checked", true);
				$("#modeWrite").attr("checked", true);
			} else {
				$("#modeRead").attr("checked", false);
				$("#modeWrite").attr("checked", false);
			}
		},

		getMode: function(sUrl, sParams) {
			var that = this;
			
			$.ajax({
				url : sUrl,
				type : "POST",
				data : sParams,
				dataType : "html",
				success : function(data){
					$("#ajaxDivResult").html(data);
					that.setMode();
				}
			});
		},
		
		makeList: function(sUrl, sParams) {
			var that = this;
			
			$.ajax({
				url : sUrl,
				type : "POST",
				data : sParams,
				dataType : "html",
				success : function(data){
					$("#" + targetElement).html(data);

					that.setUnbinding();
					that.setBinding();
					that.initPage();

					if ($("#nodata").html() != null) {
					}
				}
			});
		},
		
		initPage: function(){
			this.initPageSize();
		},
		     
		initPageSize: function(){
		    var msg = "";
			
			// warp
			var valueGwpw = getObjectValue("#warp", "width"); 
			var gwpw = (valueGwpw == null) ? 0 : valueGwpw; // 대상 전체 폭
			var valueGwph = getObjectValue("#warp", "height"); 
			var gwph = (valueGwph == null) ? 0 : valueGwph; // 대상 전체 높이
			msg = appendMessage(msg, "#warp");
			
			setObjectValue("#container", "width", Math.round(gwpw - 40));
			
			// container
			var valueGcw = getObjectValue("#container", "width"); 
			var gcw = (valueGcw == null) ? 0 : valueGcw; // 대상 전체 폭
			var valueGch = getObjectValue("#container", "height"); 
			var gch = (valueGch == null) ? 0 : valueGch; // 대상 전체 높이
			msg = appendMessage(msg, "#container");
			
			// contants
			setObjectValue("#contants", "width", Math.round(gcw - 180 - 10));
			msg = appendMessage(msg, "#contants");
			
			// formtitle
			var valueGftw = getObjectValue("#formtitle", "width");
			var gftw = (valueGftw == null) ? 0 : valueGftw; // 대상 전체 폭
			var valueGfth = getObjectValue("#formtitle", "height"); 
			var gfth = (valueGfth == null) ? 0 : valueGfth; // 대상 전체 높이
			
			// formlist
			var valueGccw = getObjectValue("#contants", "width"); 
			var gccw = (valueGccw == null) ? 0 : valueGccw; // 대상 전체 폭
			var valueGcch = getObjectValue("#contants", "height"); 
			var gcch = (valueGcch == null) ? 0 : valueGcch; // 대상 전체 높이

			setObjectValue("#formlist2l", "height", Math.round(gcch - gfth - 35));
			setObjectValue("#formlist2c", "height", Math.round(gcch - gfth - 35));
			setObjectValue("#formlist2r", "height", Math.round(gcch - gfth - 35));
			
			var formw = getObjectValue("#formlist2l", "width") + getObjectValue("#formlist2c", "width"); 
			setObjectValue("#formlist2r", "width", Math.round(gccw - formw - 30));
			msg = appendMessage(msg, "#formlist2r");
			
			$(".LoggingMessage").html(msg);
		}
};

$(document).ready(function(){
	pmModule.loadList();
	pmModule.initPage();
});

$(window).resize(function(){
	pmModule.initPage();
});
</script>
</body>
</html>
